package subject_set.interview.Day3_25_meituan; /**
 * @author haomin
 * @date 2023/03/25 19:58
 **/
import java.util.*;

public class Main2{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] str1 = in.nextLine().trim().split(" ");
        int[] arr1 = new int[str1.length];
        for(int i = 0; i < arr1.length; ++i) {
            arr1[i] = Integer.parseInt(str1[i]);
        }

        String[] str2 = in.nextLine().trim().split(" ");
        int[] arr2 = new int[str2.length];
        for(int i = 0; i < arr2.length; ++i) {
            arr2[i] = Integer.parseInt(str2[i]);
        }

        String[] str3 = in.nextLine().trim().split(" ");
        int[] arr3 = new int[str3.length];
        for(int i = 0; i < arr3.length; ++i) {
            arr3[i] = Integer.parseInt(str3[i]);
        }

        Arrays.sort(arr2);
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < arr1[1]; ++i) {
            int j = 0;
            while(arr3[i] >= arr2[j] * arr2[j]) {
                arr3[i] -= arr2[j] * arr2[j];
                j++;
            }
            if(i != arr1[1]-1) {
                sb.append(j).append(" ");
            }else sb.append(j);
        }
        System.out.println(sb.toString());
    }
}